package org.insia.smartposse.struts.action;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
 * Change the user's language.
 * 
 * @author sok hout
 *
 */
public class ChangeLocaleAction extends Action {
	@SuppressWarnings("unused")
	private static Logger _logger = Logger.getLogger(ChangeLocaleAction.class);

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
	throws Exception {
		String locale = request.getParameter("locale");
		if (locale != null && locale.length() > 0) {
			try {
				Locale loc = new Locale(locale);
				setLocale(request, loc);
			} catch (Throwable t) {
				
			}
		}
		
		return mapping.findForward("success");
	}

}
